<?php
namespace Action;

class Privilege {
	public function index() {
		global $o;
		require_once ROOT . '/template/privilege_index.html';
	}
	
	public function ls() {
		global $o;
		$aParam = array (
				'page' => $_GET ['pageIndex'],
				'limit' => $_GET ['pageSize'] ? $_GET ['pageSize'] : $o->Config->get ( 'base.limit' ),
				'sort' => array (
						$_GET ['sortField'] => $_GET ['sortOrder'] 
				) 
		);
		$aList = $o->Model->Privilege->ls ( $aParam );
		exit ( json_encode ( $aList ) );
	}
	
	public function save() {
		global $o;
		$aInfo = json_decode ( $_POST ['info'], true );
		if ($aInfo [0] ['id']) {
			exit ( $o->Model->Privilege->update ( $aInfo [0] ) );
		} else {
			exit ( $o->Model->Privilege->add ( $aInfo [0] ) );
		}
	}
	
	public function remove() {
		global $o;
		exit ( $o->Model->Privilege->remove ( intval ( $_POST ['id'] ) ) );
	}
}
?>